<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://unpkg.com/vue/dist/vue.min.js"></script>  
</head>
<body>
    <div id="app">
        <template v-if="type === 'name'">
            <label>用户名:</label>
            <input placeholder="输入用户名">
        </template>
        <template v-else>
            <label>邮箱:</label>
            <input placeholder="输入邮箱">
        </template>
        <button @click="handleToggleClick">切换输入类型</button>
    </div>
    <script>
    var app = new Vue({
        el: '#app',
        data: {
            type: 'name'
        },
        methods: {
            handleToggleClick: function() {
                this.type = this.type === 'name' ? 'mali' :'name';
            }
        }
    })
    </script>
</body>
</html>